//
//  StoreItemView.m
//  HomePage
//
//  Created by xiong qi on 13-4-24.
//  Copyright (c) 2013年 winston. All rights reserved.
//

#import "StoreItemView.h"

@implementation StoreItemView
@synthesize delegate,dataSource;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.exclusiveTouch= YES;
        self.clipsToBounds = YES;
        
        UIImageView * backgroundView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        [self addSubview:backgroundView];
        [backgroundView release];
        [backgroundView setImage:[UIImage imageNamed:@"Store_Image_BG"]];
        
        imageView = [[UIImageView alloc] initWithFrame:CGRectMake(3, 2, frame.size.width-6, frame.size.height-6)];
        [self addSubview:imageView];
        [imageView release];
        imageView.clipsToBounds = YES;
//        imageView.backgroundColor = [UIColor blackColor];
        imageView.contentMode = UIViewContentModeScaleAspectFill;
        
        
        UIView * titlebackgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, imageView.frame.size.height-30, imageView.frame.size.width, 30)];
        [imageView addSubview:titlebackgroundView];
        [titlebackgroundView release];
        titlebackgroundView.backgroundColor = [UIColor colorWithRed:0.29 green:0.29 blue:0.29 alpha:1.0];
        
        titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, titlebackgroundView.frame.size.width-10, titlebackgroundView.frame.size.height)];
        titleLabel.backgroundColor = [UIColor clearColor];
        titleLabel.textAlignment = NSTextAlignmentLeft;
        titleLabel.textColor = [UIColor whiteColor];
        titleLabel.font = [UIFont fontWithName:@"Arial" size:15];
        [titlebackgroundView addSubview:titleLabel];
        [titleLabel release];
        

    }
    return self;
}

-(void)LoadTitle:(NSString *)title ImagePath:(NSString *)path
{
    titleLabel.text = title;
    UIImage * image = [[UIImage alloc] initWithContentsOfFile:path];
    imageView.image = image;
    [image release];
}

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    if ([self.delegate respondsToSelector:@selector(ItemBeTouch:)]) {
        [self.delegate performSelector:@selector(ItemBeTouch:) withObject:self];
    }
}

-(void)dealloc
{
    self.delegate = nil;
    self.dataSource = nil;
    [super dealloc];
}

@end
